/**
 * Created by jianglinjie on Mon Oct 09 2017
 * @flow
 */
'use strict';
const SERVICE_NAME = 'FULLSTACK_CLIENT_SERVICE_ERRPR';

export default class ServiceError extends Error {
  errorCode: string;

  constructor(errorCode: string, message: string) {
    super(message);
    this.errorCode = errorCode;
    this.name = SERVICE_NAME;
  }
}

export function isServiceError(err: any): boolean {
  if (err.name === SERVICE_NAME && err.errorCode) {
    return true;
  }

  return false;
}